package com.atguigu.staService.controller;


import com.atguigu.commonutils.R;
import com.atguigu.staService.service.StatisticsDailyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-06-15
 */
@RestController
@RequestMapping("/staService/sta")
//@CrossOrigin
public class StatisticsDailyController {
    @Resource
    private StatisticsDailyService staService;

    @ApiOperation("统计某一天的注册人数,生成统计数据")
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day) {
        staService.registerCount(day);
        return R.ok();
    }

    @ApiOperation("图表显示，返回两部分数据，日期JSON数组，数量JSON数组")
    @GetMapping("showChart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin, @PathVariable String end, @PathVariable String type) {
        Map<String, Object> map = staService.getChartData(begin, end, type);
        return R.ok().data(map);
    }
}

